package version1_2_1;

import version1_1.User;

import java.util.Scanner;

/**
 * @program:IntelliJ IDEA
 * @Description:人类继承用户
 * @author:Mr.CheCheHuiBujianO
 * @data: 2022/7/12 15:58
 */
public class People extends User {
    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public void setName() {
        System.out.println("请输入你的名字");
        Scanner in = new Scanner(System.in);
        String peopleName = in.nextLine();
        this.name = peopleName;
    }

    @Override
    public String getGesture() {
        return this.gesture;
    }

    @Override
    public void setGesture() {
        System.out.println("请输入你需要出的手势(使用数字)0.剪刀 1.石头 2.布");
        Scanner in = new Scanner(System.in);
        int gesture = -1;
        //使用异常捕获机制，对合法输入进行判断
        while (in.hasNextLine()) {
            try {
                gesture = in.nextInt();
                this.gesture = this.GestureGroup[gesture];
                return;
            } catch (Exception e){
                System.out.println("请检查你输入！！！");
                System.out.println("请输入你需要出的手势(使用数字)0.剪刀 1.石头 2.布");
                in.nextLine();
            }
        }
    }
}
